#ifndef __CCALL_FUNC_INSTANT_H__
#define __CCALL_FUNC_INSTANT_H__

#include "common.h"

class CCallFuncInstant : public CCActionInstant 
{
public:
    CCallFuncInstant()
        : m_pSelectorTarget(NULL)
        , m_pCallFuncO(NULL)
		, m_pObject(NULL)
    {
    }

    virtual ~CCallFuncInstant()
    {
    }

    static CCallFuncInstant* create(CCObject* pSelectorTarget, SEL_CallFuncO pCallFuncO, CCObject* pObj = NULL);

    virtual bool initWithTarget(CCObject* pSelectorTarget, CCObject* pObj = NULL);

    virtual void execute();
    virtual void update(float time);
    CCObject * copyWithZone(CCZone *pZone);

    inline CCObject* getTargetCallback()
    {
        return m_pSelectorTarget;
    }

    inline void setTargetCallback(CCObject* pSelectorTarget)
    {
        if (pSelectorTarget != m_pSelectorTarget)
        {
            //CC_SAFE_RETAIN(pSelectorTarget);
            //CC_SAFE_RELEASE(m_pSelectorTarget);
            m_pSelectorTarget = pSelectorTarget; 
        }
    }
    
	inline CCObject* getObject()
	{
		return m_pObject;
	}
	inline void setObject(CCObject* pObj)
	{
		if (pObj != m_pObject)
		{
			//CC_SAFE_RELEASE(m_pObject);
			m_pObject = pObj;
			//CC_SAFE_RETAIN(m_pObject);
		}
	}
protected:
    CCObject*		m_pSelectorTarget;
    SEL_CallFuncO   m_pCallFuncO;
	CCObject*		m_pObject;
};

#endif  // __CCALL_FUNC_INSTANT_H__